/*
 * Created on Mar 23, 2006
 *
 */
package org.mushroomdb.storedprocedures;

import org.mushroomdb.engine.EvaluationEngine;
import org.mushroomdb.query.Query;
import org.mushroomdb.service.ServiceManager;

/**
 * DROP PROCEDURE procedure_name;
 * 
 * @author mchiodi
 */
public class DropProcedureQuery extends Query {
	private String name;

	/**
	 * Constructs a new DropProcedureQuery. 
	 */
	public DropProcedureQuery(String name) {
		super();
		this.name = name;
	}

	/**
	 * @see org.mushroomdb.query.Query#execute(org.mushroomdb.engine.EvaluationEngine)
	 */
	public Object execute(EvaluationEngine evaluationEngine) {
		StoredProceduresService storedProceduresService = (StoredProceduresService) ServiceManager.getInstance().getService(StoredProceduresService.class);
		StoredProcedure storedProcedure = storedProceduresService.getProcedureByName(this.name);
		if (storedProcedure != null) {
			return new Boolean(storedProceduresService.removeProcedure(storedProcedure));
		} else {
			return Boolean.FALSE;
		}
	}

}
